import request from '@/utils'

// 用户登录接口
export const loginApi = (data) => request({
  method: 'POST',
  url: '/user/login',
  data
})
// 获取轮播图
export const getSwiperApi = () => request({
  url: '/home/swiper'
})
// 获取城市列表
// level  1表示所有数据，2表示城市中区的数据
export const getCityListApi = (num) => request({
  url: '/area/city',
  params: {
    level: num
  }
})

// 租房小组
export const getGroupsApi = (area) => request({
  url: '/home/groups',
  params: {
    area
  }
})
// 根据条件 查询房屋
export const getHousesApi = ({ cityid, area, subway, rentType, price, more, roomType, oriented, characteristic, floor, start, end }) => request({
  url: '/houses',
  params: { cityid, area, subway, rentType, price, more, roomType, oriented, characteristic, floor, start, end }
})
// 查询条件
export const cityRulesApi = (cityId) => request({
  url: '/houses/condition',
  params: {
    id: cityId
  }
})
// 获取用户列表
export const getUserListApi = (val) => request({
  url: '/admin/users',
  method: 'GET',
  headers: {
    authorization: val
  }
})
// 获取用户信息 /user

export const getUserInfoApi = (val) => request({
  url: '/user',
  method: 'GET',
  headers: {
    authorization: val
  }
})
// 查询房屋具体信息
export const houseInfoApi = ({ id }) => request({
  url: `/houses/${id}`,
  method: 'GET'
})
// 地图上查询房源数据
export const getMapHouseApi = (id) => request({
  url: '/area/map',
  params: {
    id
  }
})

// 查看收藏列表
export const getFavoRitesApi = (val) => request({
  url: '/user/favorites',
  headers: {
    authorization: val
  }
})
// 查看已发布房源列表列表
export const getRentHoustListApi = (val) => request({
  url: '/user/houses',
  headers: {
    authorization: val
  }
})
// 发布房源
export const publishHouseApi = ({ body, token }) => request({
  url: '/user/houses',
  method: 'POST',
  data: body,
  headers: {
    authorization: token
  }
})
// 小区关键词查询
export const getCommunityApi = ({ name, id }) => request({
  url: '/area/community',
  params: {
    name,
    id
  }
})
// 发布房屋所需条件
export const HouseParamsApi = () => request({
  url: '/houses/params'
})
// 上传房屋图像
export const HouseImgApi = (file) => request({
  url: '/houses/image',
  method: 'POST',

  data: file

})
